var opinionPrice;

/**
 * 设置结果接收对象
 * @param _opinionPrice
 */
function setModel(_opinionPrice) {
    if (_opinionPrice == undefined || !(_opinionPrice instanceof com.jf.crawl.model.OpinionPrice)) {
        throw new java.lang.Exception("opinionPrice 对象为空");
    }
    log.info("opinionPrice {}", _opinionPrice)
    opinionPrice = _opinionPrice;
}

function crawler() {
    //投哪儿
//     1个月--7.2%
//     3个月--7.6%
//     6个月--8.5%
//     12个月--9.8%
//     24个月--10.4
    var html = Get("http://www.touna.cn/");
    var document = Jsoup.parse(html);
    var items = document.select("#autoDetail .pro-item");
    for (var i = 0; i < items.size(); i++) {
        var item = items.get(i);
        var month = item.select(".pro-time > em").text();
        var price = item.select(".pro-income > em").text().trim().replace("%","");
        if(price.contains("+")){
            price = price.split("+")[0];
        }
        if ("1个月".equals(month)) {
            opinionPrice.setOneMonth(commonUtil.string2Decimal(price));
        } else if ("3个月".equals(month)) {
            opinionPrice.setThreeMonth(commonUtil.string2Decimal(price));
        } else if ("6个月".equals(month)) {
            opinionPrice.setSixMonth(commonUtil.string2Decimal(price));
        } else if ("12个月".equals(month)) {
            opinionPrice.setOneYear(commonUtil.string2Decimal(price));
        } else if ("24个月".equals(month)) {
            opinionPrice.setTwoYear(commonUtil.string2Decimal(price));
        } else if ("36个月".equals(month)) {
            opinionPrice.setThreeYear(commonUtil.string2Decimal(price));
        }
    }
    return true;
}